<?php
function ping_host($host_id) {
	$starttime = microtime ( true );
	$file = fsockopen ( $host_id, 23, $errno, $errstr, 10 ); // 10
	$stoptime = microtime ( true );
	$status = 0;

	if (! $file)
		$status = - 1; // Site is down
	else {
		fclose ( $file );
		$status = ($stoptime - $starttime) * 1000;
		$status = floor ( $status );
	}

	return $status;
}
?>